<?php
	session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
  
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">

    <title>Quản lý site</title>
<link rel="stylesheet" type="text/css" href="../resource/css/login.css"  />
</head>
<body>
<?php
include("connectDB.php");
if(isset($_POST['ok']))
{

	$user = $_POST["txt_username"];
	$pass = $_POST['txt_password'];
	
	
	$sql_login = "SELECT * FROM  useradmin WHERE  taikhoan = '".$user."' AND matkhau='".$pass."' ";
	echo $sql_login;
	
	$result_login = mysql_query($sql_login);
	$row_user = mysql_fetch_array($result_login);
	$uname = $row_user['taikhoan'];
	$id = $row_user['id'];
	
	if(mysql_num_rows($result_login)==0)
	{
		$_SESSION["dangnhap"] =1;
?>

<script language = "javascript">
alert("Tên đăng nhập hoặc mật khẩu không đúng !!");
self.location = "login.php";
</script>
<?php
	
	}
	else
	{
		header("location: index.php");
				
		$_SESSION["Name"] = $user;
		$_SESSION["id_user"] = $id;
			
	
	
	
?>
<script language = "javascript">

self.location = "./";
</script>
<?php
	}
}
?><div id="wrapper">

    <div id="main">
        <div class="login">
            <h2>Hệ Thống Đăng Nhập</h2>
            <div class="lock">
                <img src="../resource/pictures/lock.png"/>
            </div>
             <div id="login-content">
                <div>
                    <div>                    
                        <form class="loginform" method="post" action="" >
                            <ul>                           
                                <li>
                                    <label>Tài khoản</label>
                                    <input name="txt_username" id="username" maxlength="" type="text">
                                </li>
                                <li>
                                    <label>Mật khẩu</label>
                                    <input name="txt_password" id="password" maxlength="" type="password">
                                </li>
                                
                            </ul>
                            <div id="smb">                            
                               
                                <input name="ok" class="submitform" value="Đăng nhập" type="submit">
                            </div>
                        </form>
                        <p style="text-align:right; padding:23px; color: #ebebeb">
                          <!--  <a class="lostpass" title="Quên mật khẩu" href="#">Quên mật khẩu?</a> -->
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body></html>